package com.sumainfor.pc.market.service.tenant.impl;

import com.sumainfor.common.utlis.ParamsCommon;
import com.sumainfor.pc.market.dao.RdPactMapper;
import net.bytebuddy.asm.Advice;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import java.io.Serializable;
import java.util.Map;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author Meng
 * @ClassName TenPaIdService
 * @date 2019/12/11 21:49
 * @description: TODO
 */
@Service
public class TenPaIdService implements Serializable {


    private ReentrantLock lock = new ReentrantLock(false);
    Logger log = LoggerFactory.getLogger(TenPaIdService.class);


     @Autowired
    RdPactMapper rdPactMapper;

     @Transactional(rollbackFor = Exception.class)
     public Integer upPaIdFlow(Map<String,Object> params){

         Integer cout = new Integer("0");
         lock.lock();

         try {
             params.put("term","7");//1 租客端 2市场部 3 工程部 4运营部 5财务部 6总经办 7发展部
             params.put("fnc",
                     this.getClass().getSimpleName() + "." + Thread.currentThread().getStackTrace()[1].getMethodName());// 创建Function名
             ParamsCommon.commonUpdateParms(params);
             System.out.println("接收完修改的参数"+params);
             if(MapUtils.getInteger(params,"nimeide")!=1){
                 params.put("IfFlowPay",2);
                 params.put("Hydropower",2);
             }
             System.out.println("1111111111111");
             System.out.println("判断完之后"+params);

             cout = rdPactMapper.updatePact(params);
         } catch (Exception e) {
             e.printStackTrace();
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚
         } finally {
             lock.unlock();
         }
         return cout;
     }


}
